//
//  RepairHistoryProcessCell.m
//  wtshoppingcite
//
//  Created by Baojia-LC on 14/11/14.
//  Copyright (c) 2014年 TW. All rights reserved.
//

#import "ComplaintProcessCell.h"

@implementation ComplaintProcessCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
    }
    return self;
}

-(void)createSubViews{
    
    _titleLabel = [self createLabelWithFrame:CGRectMake(5, 15, 80, 20) text:@"" font:18 textAli:NSTextAlignmentCenter textColor:MAIN_BLUE_COLOR];
    [self.contentView addSubview:_titleLabel];
    
    _curTimeLabel = [self createLabelWithFrame:CGRectMake(_titleLabel.right+5, 10, 200, 20) text:@"" font:14 textAli:NSTextAlignmentLeft textColor:MAIN_GRAY_COLOR];
    [self.contentView addSubview:_curTimeLabel];
    
    _remarkLabel = [self createLabelWithFrame:CGRectMake(_titleLabel.right+5, 10, 200, 20) text:@"" font:14 textAli:NSTextAlignmentLeft textColor:MAIN_GRAY_COLOR];
    [self.contentView addSubview:_remarkLabel];
    
    _timeLabel = [self createLabelWithFrame:CGRectMake(_remarkLabel.left, _remarkLabel.bottom+3, 200, 20) text:@"" font:14 textAli:NSTextAlignmentLeft textColor:MAIN_GRAY_COLOR];
    [self.contentView addSubview:_timeLabel];
    
    _processorLabe = [self createLabelWithFrame:CGRectMake(_timeLabel.left, _timeLabel.bottom+3, 200, 20) text:@"" font:14 textAli:NSTextAlignmentLeft textColor:MAIN_GRAY_COLOR];
    [self.contentView addSubview:_processorLabe];
    
    _phoneLabel = [self createLabelWithFrame:CGRectMake(_processorLabe.left, _processorLabe.bottom+3, 200, 20) text:@"" font:14 textAli:NSTextAlignmentLeft textColor:MAIN_GRAY_COLOR];
    [self.contentView addSubview:_phoneLabel];
    
}

-(void)setData:(NSDictionary *)data{
    
    if(_data != data){
        _data = data;
        
        _titleLabel.text = ObjToString(data[@"title"]);
        NSString* status = ObjToString(data[@"status"]);
        switch (status.intValue) {
            case 0:
            {
                _curTimeLabel.text = ObjToString(data[@"curtime"]);
                _remarkLabel.text = ObjToString(data[@"remark"]);
                _timeLabel.text = ObjToString(data[@"exptime"]);
                _remarkLabel.top = _curTimeLabel.bottom+10;
                _timeLabel.top = _timeLabel.bottom+3;
            }
            break;
            case 1:
            case 2:
            {
                _curTimeLabel.alpha = 0;
                _processorLabe.text = ObjToString(data[@"processor"]);
                _phoneLabel.text = ObjToString(data[@"phone"]);
                _timeLabel.text = ObjToString(data[@"time"]);
                _remarkLabel.text = ObjToString(data[@"remark"]);

            }break;
            default:
            break;
        }
    }
}

-(UILabel*)createLabelWithFrame:(CGRect)frame text:(NSString*)text font:(int)font textAli:(NSTextAlignment)alig textColor:(UIColor*)tc{
    if(text == nil)
    text = @"";
    UILabel* label = [[UILabel alloc] initWithFrame:frame];
    label.text = text;
    label.font = [UIFont systemFontOfSize:font];
    label.textAlignment = alig;
    label.textColor = tc;
    label.backgroundColor = [UIColor clearColor];
    return label;
}

@end
